package com.aaa.oauth;

import com.aaa.entity.ResultCode;
import com.aaa.entity.ResultMsg;
import com.aaa.utils.ResponseUtils;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Component
public class ClientAuthenticationEntryPoint implements AuthenticationEntryPoint {
    //令牌过期
    @Override
    public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
        ResultMsg resultMsg = ResultMsg.error(ResultCode.ACCESS_TOKEN_EXPIRED.getCode(), ResultCode.ACCESS_TOKEN_EXPIRED.getMsg());
        ResponseUtils.result(httpServletResponse,resultMsg);
    }
}
